//
//  TextModelCell.m
//  Otaku
//
//  Created by lanou3g on 16/5/16.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "TextModelCell.h"

@interface TextModelCell()
@property (weak, nonatomic) IBOutlet UIImageView *userImageView;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;


@end
static CGFloat height = 0;
@implementation TextModelCell

- (void)setModel:(TextModel *)model {
    _model = model;
    self.userImageView.layer.cornerRadius = 15;
    self.userImageView.layer.masksToBounds = YES;
    
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:self.model.user[@"avatar_url"]]];
    self.userNameLabel.text = self.model.user[@"name"];
    self.contentLabel.text = self.model.text;
    CGSize maxSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 2 * 10, MAXFLOAT);
    CGFloat textHeight = [self.model.text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil].size.height;
    height = textHeight + 60;
    
}

+ (CGFloat)cellHeight {
    return height;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
